DEFINITION MODULE Text;


(*
*    Copyright (c) 1985, 1986 by
*    Djavaheri Bros., Foster City, California.
*    All Rights Reserved.
*
*    This software is furnished under a license and may be used and copied
*    only  in accordance with  the  terms  of  such  license and  with the
*    inclusion of the above copyright notice.  This software or  any other
*    copies thereof may not be provided or otherwise made available to any
*    other  person.   No title to and ownership of the  software is  herby
*    transferred.
*
*    The information in this software is  subject to change without notice
*    and  should  not be construed as a commitment by Djavaheri Bros.   No
*    warranty is implied or expressed.
*
*  SCCID  = "1.2    9/19/86"; 
*)
FROM Files IMPORT File, FileState;

EXPORT QUALIFIED
    EOL,
    ReadChar,     ReadLn,       ReadString, ReadLine,
    UndoRead,     CondRead,
    WriteChar,    WriteString,  WriteLn;


PROCEDURE EOL      ( file    : File)
                             : BOOLEAN;
(* Returns true if last operation was not performed due to end of line or
   error *)

PROCEDURE ReadChar ( file    : File;
                 VAR ch      : CHAR;
                 VAR state   : FileState);
(* Read a char from a TextFile.  If the file is the standard input file,
   then echoing is controlled by Module StandardIO *)

PROCEDURE ReadString(file    : File;
                 VAR str     : ARRAY OF CHAR;
                 VAR state   : FileState);
(* Read a string from a text file until EOL, EOF, or end of string *)

PROCEDURE ReadLine(file    : File;
                 VAR str     : ARRAY OF CHAR;
                 VAR state   : FileState);

PROCEDURE ReadLn   ( file    : File;
                 VAR state   : FileState);
(* eat characters (without echo) until EOL, then eat EOL (with echo) *)

PROCEDURE UndoRead(  file    : File;
                 VAR state   : FileState);
(* allow most recently read CHAR to be read again *)

PROCEDURE CondRead(  file    : File;
                 VAR ch      : CHAR;
                 VAR success : BOOLEAN;
                 VAR state   : FileState);
(* attempt to read a char: return TRUE in "success" if read succeeds; return
   FALSE in "success" if read fails.  If read fails, value in "ch" is
   undefined *)

PROCEDURE WriteChar( file    : File;
                     ch      : CHAR;
                 VAR state   : FileState);
(* Write a single character to a text file *)

PROCEDURE WriteString(file   : File;
                 VAR str     : ARRAY OF CHAR;
                 VAR state   : FileState);
(* Write a string of characters to a text file *)

PROCEDURE WriteLn  ( file    : File;
                 VAR state   : FileState);
(* Write an EOL to a text file *)

END Text.
